package javabase.biji;

import org.junit.Test;

/**
 * @Auther: luzhanshi
 * @Date: 2021/2/1 - 02 - 01 - 16:54 
 * @Description: javabase.biji
 * @version: 1.0
 */
public class _24内部类 {

    /**
     * 成员内部类****************************
     */
    public class OutClass {
        public String name = "十点多";

        public class InnerClass {
            public String name2 = name;
        }

        public void show() {
            InnerClass innerClass = new InnerClass();
            System.out.println(innerClass.name2);
        }

    }

    //访问内部类的方法1
    OutClass.InnerClass innerClass = new OutClass().new InnerClass();
    //        访问内部类方法2
    OutClass outClass = new OutClass();

    public void test() {
        //        访问内部类方法2
        OutClass outClass = new OutClass();
        outClass.show();
    }

    /**
     * 局部内部类*************************************
     */
    public class InnerTest {
        private int num = 10;

        public void show() {
            class Inner {
                public void methord() {
                    System.out.println(num);
                }
            }
            Inner inner = new Inner();
            inner.methord();
        }
    }





}
